<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>



    <body>
        <div class="easyui-layout" data-options="fit:true">
            <div data-options="region:'north',split:true,border:false" style="height: 80px;">
                <form id="searchForm">
                    <table>
                        <tr>
                            <td><a id="btn_add" class="easyui-linkbutton" data-options="group:'g1',iconCls:'icon-add'">添加</a></td>
                            <td><a id="btn_dele" class="easyui-linkbutton" data-options="group:'g1',iconCls:'icon-remove'">删除</a></td>
                            <td><a onclick="grid.datagrid('reload');" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'ext-icon-arrow_refresh'">刷新</a></td>
                        </tr>
                    </table>
                    <table>
                        <tr>
                            <td>用户名称</td>
                            <td>
                                <input name="idSch" class="textbox" style="width: 120px; height: 22px;" />
                            </td>
                            <td>创建时间</td>
                            <td>
                                <input name="createdStartSch" class="easyui-datebox" style="width: 100px" />
                                <input name="createdEndSch" class="easyui-datebox" style="width: 100px" />
                            </td>
                            <td><a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'ext-icon-zoom',plain:true" onclick="grid.datagrid('load',fw.serializeObject($('#searchForm')));">过滤</a> <a href="javascript:void(0);" id="reset_searchFilter" class="easyui-linkbutton" data-options="iconCls:'ext-icon-zoom_out',plain:true" onclick="$('#searchForm input').val('');grid.datagrid('load',{});">重置过滤</a></td>
                        </tr>
                    </table>
                </form>
            </div>

            <div data-options="region:'center',border:false">
                <table id="grid"></table>
            </div>

            <div data-options="region:'east',split:true,border:false" style="width: 50%; padding: 5px;">
                <form id="form" name="form" method="post" class="form">
                    <fieldset>
                        <legend>
                            基本信息--<span id="operateMode_title">添加模式</span>
                        </legend>
                        <table class="table">
                            <tbody>
                                <tr>
                                    <th>id:</th>
                                    <td>
                                        <input id="id" readonly="readonly" name="id" class="textbox" style="height: 22px;" />
                                    </td>
                                </tr>
                                 <tr>
                                    <th>进入时间:</th>
                                    <td>
                                        <input name="arriveTime" class="easyui-datebox" style="height: 22px;">
                                    </td>
                                </tr>
                                 <tr>
                                    <th>离开时间:</th>
                                    <td>
                                        <input name="leaveTime" class="textbox" style="height: 22px;">
                                    </td>
                                </tr>
                                 <tr>
                                    <th>agent单号:</th>
                                    <td>
                                        <input name="agentRef" class="textbox" style="height: 22px;">
                                    </td>
                                </tr>
                                <tr> 
                                    <th>traveldays:</th>
                                    <td>
                                        <input name="travelDays" class="textbox" style="height: 22px;">
                                    </td>
                                </tr>
                                <tr>
                                    <th>totalprice:</th>
                                    <td>
                                        <input name="totalPrice" class="textbox" style="height: 22px;">
                                    </td>
                                </tr>
                                <tr>
                                    <th>formnumber:</th>
                                    <td>
                                        <input name="formNumber" class="textbox" style="height: 22px;">
                                    </td>
                                </tr>
                                <tr>
                                    <th>tax:</th>
                                    <td>
                                        <input id="tax" name="tax" class="textbox" style="height: 22px;" />
                                    </td>
                                </tr>
                                <tr>
                                    <th>time:</th>
                                    <td>
                                        <input id="time" name="time" class="textbox" style="height: 22px;" />
                                    </td>
                                </tr>
                                <tr>
                                    <th>filepath:</th>
                                    <td>
                                        <input id="filepath" name="filepath" class="textbox" style="height: 22px;" />
                                    </td>
                                </tr>
                                <th>操作</th>
                                <td><a id="operateMode_submit" class="easyui-linkbutton" data-options="iconCls:'icon-save'">确定</a> <a id="operateMode_reset" class="easyui-linkbutton" data-options="iconCls:'icon-reload'">重置</a></td>
                                </tr>
                            </tbody>
                        </table>
                    </fieldset>
                </form>
            </div>
        </div>
        <script type="text/javascript">
            $(function() {
                var gird;
                grid = $('#grid').datagrid({
                    fit: true,
                    border: false,
                    collapsible: false,
                    rownumbers: true,
                    pagination: true,
                    singleSelect: true,
                    rownumbers: true,
                    url: ctx + 'listAusDataset.do',
                    columns: [
                        [{
                            field: 'id',
                            title: 'id'
                        }, {
                            field: 'arriveTime',
                            title: '到达时间',
                            sortable: true
                            
                        }, {
                            field: 'leaveTime',
                            title: '离开时间',
                            sortable: true
                        }, {
                            field: 'agentRef',
                            title: 'Agent单号'
                        }
                        , {
                            field: 'orginData',
                            title: '原始数据',
                            hidden: 'true'
                        }, {
                            field: 'travelDays',
                            title: '旅游天数'
                        }, {
                            field: 'totalPrice',
                            title: '总价格'
                        }, {
                            field: 'formNumber',
                            title: '公司单号'
                        }, {
                            field: 'tax',
                            title: '税'
                        }, {
                            field: 'time',
                            title: '时间',
                            sortable: true
                        }, {
                            field: 'filepath',
                            title: '文件路径'
                        }, ]
                    ],
                    onLoadSuccess: function(data) {
                        $('.iconImg').attr('src', fw.pixel_0);
                    },
                    onClickRow: function(index, row) {
                        $("#form").form("load", row);
                        $("#operateMode_title").html("修改模式");
                    }
                });

                
                //添加操作
                $("#btn_add").click(function() {
                    $("#operateMode_title").html("添加模式");
                    $('#grid').datagrid("unselectAll");
                    $("#id").attr("value", 0);
                    $("#form").form("reset");
                })

                //删除操作
                $("#btn_dele").click(function() {
                    var rows = $('#grid').datagrid('getSelections');
                    if (rows <= 0) {
                        $.messager.show({
                            title: message.title.normal,
                            msg: message.grid_select,
                            timeout: message.timeout,
                            showType: message.showType
                        });
                    } else {
                        $.messager.confirm(message.title.askTitle, message.dele_comfirm, function(r) {
                            if (r) {
                                var idValue = $("#form input[name='id']").val();
                                $.post(ctx + "delAusDataset.do", {
                                    id: idValue
                                }, function(result) {
                                    if (result.success) {
                                        $.messager.show({
                                            title: message.title.normal,
                                            msg: message.dele_success,
                                            timeout: message.timeout,
                                            showType: message.showType
                                        });
                                        grid.datagrid('reload');
                                    } else {
                                        $.messager.show({
                                            title: message.title.normal,
                                            msg: message.dele_fail,
                                            timeout: message.timeout,
                                            showType: message.showType
                                        });
                                    }
                                }, 'json');
                                $("#btn_add").click();
                            }
                        });
                    }
                })

                //确认提交操作
                $("#operateMode_submit").click(function() {
                        var idValue = $("#form input[name='id']").val();
                        if ($('#form').form('validate')) {
                            if (idValue > 0) {
                                //修改
                                $.post(ctx + "updateAusDataset.do", fw.serializeObject($('form')), function(result) {
                                    if (result.success) {
                                        $.messager.show({
                                            title: message.title.normal,
                                            msg: message.update_success,
                                            timeout: message.timeout,
                                            showType: message.showType
                                        });

                                        grid.datagrid("reload");

                                        //重新获取form信息内容
                                        $("#form").form("load", ctx + "getAusDatasetBy${context.javaPKNamedaxie}.do?id=" + idValue);
                                    }
                                }, 'json');
                            } else {
                                //添加
                                $.post(ctx + "addAusDataset.do", fw.serializeObject($('form')), function(result) {
                                    if (result.success) {
                                        $.messager.show({
                                            title: message.title.normal,
                                            msg: message.add_success,
                                            timeout: message.timeout,
                                            showType: message.showType
                                        });
                                        grid.datagrid("reload");
                                        $("#form").form("reset");
                                    }
                                }, 'json');
                            }
                        }
                    })
                    //重置操作
                $("#operateMode_reset").click(function() {
                    var idValue = $("#form input[name='id']").val();
                    if (idValue > 0) {
                        $("#form").form("load", ctx + "getAusDatasetBy${context.javaPKNamedaxie}.do?id=" + idValue);
                    } else {
                        $("#form").form("reset");
                    }
                })


            });
        </script>
    </body>

    </html>